import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class SimpleTextTab extends StatelessWidget {
  final List<String> types;
  final int typeIndex;
  final double height;
  final TextStyle selectStyle;
  final TextStyle normalStyle;
  final Function(int index) onTapItem;

  const SimpleTextTab({
    super.key,
    required this.types,
    required this.typeIndex,
    required this.onTapItem,
    this.height = 42,
    this.selectStyle = const TextStyle(fontSize: 12, color: Color(0xffDB361F)),
    this.normalStyle = const TextStyle(fontSize: 12, color: Color(0xffffffff)),
  });

  @override
  Widget build(BuildContext context) {
    return ListView.separated(
      shrinkWrap: true,
      scrollDirection: Axis.horizontal,
      physics: const NeverScrollableScrollPhysics(),
      padding: EdgeInsets.zero,
      itemCount: types.length,
      itemBuilder: (context, int index) {
        final type = types[index];
        return GestureDetector(
          onTap: () {
            onTapItem.call(index);
          },
          behavior: HitTestBehavior.opaque,
          child: Container(
            height: 42.h,
            alignment: Alignment.center,
            child: Text(
              type,
              style: index == typeIndex ? selectStyle : normalStyle,
            ),
          ),
        );
      },
      separatorBuilder: (_, __) => Container(
        height: height,
        alignment: Alignment.center,
        margin: EdgeInsets.symmetric(horizontal: 6),
        child: Text(
          '/',
          style: normalStyle,
        ),
      ),
    );
  }
}
